<?php
$salt = !empty($model->salt)?$model->salt:substr(md5(time), -16);
?>

<div class="form">

    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'admin-form',
        'enableAjaxValidation' => true,
        'enableClientValidation' => false,
));
    ?>
    <?php echo $form->errorSummary($model); ?>

    <div class="row">
        <?php echo $form->labelEx($model, 'role_id'); ?>
        <?php echo $form->dropDownList($model, 'role_id', array('' => '分组') + CHtml::listData(Role::model()->findAll(), 'id', 'role_name')); ?>
        <?php echo $form->error($model, 'role_id'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'user_name'); ?>
        <?php echo $form->textField($model, 'user_name', array('size' => 50, 'maxlength' => 50)); ?>
        <?php echo $form->error($model, 'user_name'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'password'); ?>
        <?php echo $form->passwordField($model, 'password', array('size' => 50, 'maxlength' => 32)); ?>
        <?php echo $form->error($model, 'password'); ?>
    </div>
    <div class="row">
        <?php echo $form->labelEx($model, 'password_repeat'); ?>
        <?php echo $form->passwordField($model, 'password_repeat', array('size' => 50, 'maxlength' => 32)); ?>
        <?php echo $form->error($model, 'password_repeat'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'salt'); ?>
        <?php echo $form->textField($model, 'salt', array('size' => 16, 'maxlength' => 16, 'readonly' => true, 'value' => $salt)); ?>
        <?php echo $form->error($model, 'salt'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'user_email'); ?>
        <?php echo $form->textField($model, 'user_email', array('size' => 50, 'maxlength' => 255)); ?>
        <?php echo $form->error($model, 'user_email'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'display_name'); ?>
        <?php echo $form->textField($model, 'display_name', array('size' => 50, 'maxlength' => 50)); ?>
        <?php echo $form->error($model, 'display_name'); ?>
    </div>

    <div class="row buttons">
        <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
    </div>

    <?php $this->endWidget(); ?>

</div><!-- form -->